<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <div id="app">
        {{ message }} {{ message + 2}}
        <div :id="message"></div>
        <ul>
            <!-- <li v-for="item in list">
                <span v-if="!item.del">{{item.title}}</span>
                <span v-else style="text-decoration: line-through;">{{item.title}}</span>
                <button v-show="!item.del">删除</button>
            </li> -->
            <todo-item v-for="item in list" :title="item.title" :del="item.del"></todo-item>
        </ul>

        <todo-list></todo-list>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    
    <script>
        Vue.component('todo-item', {
            props: {
                title: String,
                del: {
                    type: Boolean,
                    default: false
                }
            },
            template:
             `
                <li>
                    <span v-if="!del">{{title}}</span>
                    <span v-else style="text-decoration: line-through;">{{title}}</span>
                    <button v-show="!del">删除</button>
                </li>
            `,
            data: function(){
                return {}
            },
            methods: {

            }
        })

        Vue.component('todo-list', {
            template:
            `
            <ul>
                <todo-item v-for="item in list" :title="item.title" :del="item.del"></todo-item>
            </ul>
            `,
            data: function() {
                return {
                    list: [
                    {
                        title: '课程1',
                        del: true
                    },
                    {
                        title: '课程2',
                        del: false
                    }
                ]
                }
            }
        })

        var vm = new Vue({
            el: '#app',
            data: {
                message: 'Hello World',
                list: [
                    {
                        title: '课程1',
                        del: true
                    },
                    {
                        title: '课程2',
                        del: false
                    }
                ]
            }
        })
    </script>
</body>
</html>